#include <iostream>
#include <vector>
#include <cstring>
#include <queue>
using namespace std;
const int N=510;
int saveteam[N];
int p[N][N]; 
int dist[N];
int st[N];
int pre[N];
int r[N];
int csaveteam[N]; 
int n,m,s,d;
int road[N];
int b[N];
int idx=0;
void dfs(int a)
{
	if(a==s)
	{
		b[idx]=a;
		return;
	}
	else
	{
		b[idx]=a;
		idx++;
		dfs(pre[a]);
	}
}
void dijkstra(int s)
{
    memset(pre,-1,sizeof pre);
    dist[s]=0;
    csaveteam[s]=saveteam[s];
    road[s]=1;
    for(int i=0;i<n;i++)
    {
    	int t=-1;
        for(int j=0;j<n;j++)
        {
            if( st[j]==0 &&( t==-1 || dist[j]<dist[t]))
            {
                t=j;
            }
        }
        st[t]=1;
        for(int j=0;j<n;j++)
        {
            if(dist[j]>dist[t]+p[t][j] ) 
            {
            	dist[j]=dist[t]+p[t][j];
            	csaveteam[j]=csaveteam[t]+saveteam[j];
            	pre[j]=t;
            	road[j]=road[t];
			}
			else if(dist[j]==dist[t]+p[t][j] && p[t][j]!=0x3f3f3f3f)
			{
				road[j]+=road[t];
				if(csaveteam[j]<saveteam[j]+csaveteam[t])
				{
					csaveteam[j]=saveteam[j]+csaveteam[t];
					pre[j]=t;
				}
			}
            
        }
    }
}
int main()
{
    memset(dist,0x3f,sizeof(dist));
    memset(p,0x3f,sizeof(p));
    cin>>n>>m>>s>>d;
    for(int i=0;i<n;i++)
    {
        cin>>saveteam[i];
    }
    for(int i=0;i<m;i++)
    {
        int a,b,c;
        cin>>a>>b>>c;
        p[b][a]=p[a][b]=min(p[a][b],c);
    }
    dijkstra(s);
    
    cout<<road[d]<<' '<<csaveteam[d];
    cout<<endl;
    dfs(d);
    
    for(int i=idx;i>0;i--)
    {
    	cout<<b[i]<<' ';
	}
	cout<<b[0];
    return 0;
    
}
